package org.jeecg.report.controller;

import com.baomidou.dynamic.datasource.annotation.DS;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.jeecg.common.api.vo.Result;
import org.jeecg.report.dto.QisSpcChartDataDTO;
import org.jeecg.report.service.IQisSpcService;
import org.jeecg.report.vo.QisSpcParameterVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * @author lichunyang
 * @ClassName QisSpcController
 * @Description SPC控制器
 */
@RestController
@AllArgsConstructor
@RequestMapping(value = "/qis/spc")
public class QisSpcController {
    @Autowired
    private IQisSpcService iQisSpcService;
    @PostMapping("/getChartInfo")
    @DS("history")
    @ApiOperation(value = "获取SPC控制图数据", notes = "传入qmSpcParameterVO")
    public Result<QisSpcChartDataDTO> getChartInfo(@RequestBody QisSpcParameterVO qisSpcParameterVO) {
        return iQisSpcService.getChartInfo(qisSpcParameterVO);
    }

    @PostMapping("/getSampleChartInfo")
    @DS("history")
    @ApiOperation(value = "获取SPC控制图数据", notes = "传入qmSpcParameterVO")
    public Result<QisSpcChartDataDTO> getSampleChartInfo(@RequestBody QisSpcParameterVO qisSpcParameterVO) {
        return iQisSpcService.getSampleChartInfo(qisSpcParameterVO);
    }

    @PostMapping("/getManualChartInfo")
    @DS("history")
    @ApiOperation(value = "获取SPC控制图数据", notes = "传入qmSpcParameterVO")
    public Result<QisSpcChartDataDTO> getManualChartInfo(@RequestBody QisSpcParameterVO qisSpcParameterVO) {
        return iQisSpcService.getManualChartInfo(qisSpcParameterVO);
    }

    /**
     * 导出excel
     *
     * @param request
     * @param qisSpcParameterVO
     */
    @RequestMapping(value = "/exportXls")
    @DS("history")
    public ModelAndView exportXls(HttpServletRequest request, QisSpcParameterVO qisSpcParameterVO) {
        return iQisSpcService.exportXls(request, qisSpcParameterVO);
    }
}
